﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Idlesoft.Utils
{
	public static class NullExtensions
	{
		#region nulls
		public static bool IsEmpty<TItem>(this IEnumerable<TItem> items) { return items != null && items.Count() == 0; }
		public static bool IsNullOrEmpty<TItem>(this IEnumerable<TItem> items) { return (items == null || items.Count() == 0); }

		public static IEnumerable<TItem> NonNull<TItem>(this IEnumerable<TItem> items)
		{
			return items.Where(item => item != null);
		}
		public static TItem[] NonNull<TItem>(this TItem[] items)
		{
			return items.NonNull().ToArray();
		}
		public static List<TItem> NonNull<TItem>(this List<TItem> items)
		{
			return items.NonNull().ToList();
		}
		#endregion nulls
	}
}
